package fr.inserm.umr915.vcfserver.bio.ucsc.wgrna;

import fr.inserm.umr915.vcfserver.xml.XmlStreamSerializer;

public class WgRna
{

	private String chrom;
	private int chromStart;
	private int chromEnd;
	private String name;
	private String type;
	public WgRna()
		{
		}
	
	public String getChrom()
	{
		return this.chrom;
	}
	public int getChromStart()
	{
		return this.chromStart;
	}
	public int getChromEnd()
	{
		return this.chromEnd;
	}
	public String getName()
	{
		return this.name;
	}
	
	public String getType()
	{
		return this.type;
	}
	@Override
	public String toString()
	{
		return this.getClass().toString() +   " 'chrom'= " + this.chrom + 
		" 'chromStart'= " + this.chromStart +  " 'chromEnd'= " + this.chromEnd + 
		" 'name'= " + this.name +  " 'type'= " + this.type;
	}
	
	
	/** XMLStreamWriter serialisation */
	public static class StaxSerializer
		implements XmlStreamSerializer<WgRna>
	   {
		@Override
		public void write(WgRna o,javax.xml.stream.XMLStreamWriter w) throws javax.xml.stream.XMLStreamException
				{
				w.writeStartElement("WgRna");
				
				w.writeStartElement("chrom");
				w.writeCharacters(String.valueOf(o.getChrom()));
				w.writeEndElement();
				w.writeStartElement("chromStart");
				w.writeCharacters(String.valueOf(o.getChromStart()));
				w.writeEndElement();
				w.writeStartElement("chromEnd");
				w.writeCharacters(String.valueOf(o.getChromEnd()));
				w.writeEndElement();
				w.writeStartElement("name");
				w.writeCharacters(String.valueOf(o.getName()));
				w.writeEndElement();
				
				w.writeStartElement("type");
				w.writeCharacters(String.valueOf(o.getType()));
				w.writeEndElement();
				w.writeEndElement();
			}
	   }
	
	public  static WgRna parse(String tokens[])
		{
		WgRna o=new WgRna();
		o.chrom=tokens[1];
		o.chromStart=Integer.parseInt(tokens[2]);
		o.chromEnd=Integer.parseInt(tokens[3]);
		o.name=tokens[4];
		
		o.type=tokens[9];
		return o;
		}
	
	public static class Binding extends com.sleepycat.bind.tuple.TupleBinding<WgRna>
		{
		@Override
		public WgRna entryToObject(com.sleepycat.bind.tuple.TupleInput in)
			{
			WgRna o=new WgRna();
			o.chrom=in.readString();
			o.chromStart=in.readInt();
			o.chromEnd=in.readInt();
			o.name=in.readString();
			o.type=in.readString();
			return o;
			}
		
		@Override
		public void objectToEntry(WgRna o,com.sleepycat.bind.tuple.TupleOutput out)
			{
			
			out.writeString(o.chrom);
			out.writeInt(o.chromStart);
			out.writeInt(o.chromEnd);
			out.writeString(o.name);
			out.writeString(o.type);
			}
	}
}
